package com.ruoyi.uni.service.impl;

import java.util.List;

import com.ruoyi.uni.domain.DcCustomer;
import com.ruoyi.uni.mapper.DcCustomerMapper;
import com.ruoyi.uni.service.IDcCustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * 客户管理Service业务层处理
 * 
 * @author hx
 * @date 2024-04-16
 */
@Service
public class DcCustomerServiceImpl implements IDcCustomerService
{
    @Autowired
    private DcCustomerMapper dcCustomerMapper;

    @Override
    public String updateStatus( Long id) {
        DcCustomer dcCustomer = dcCustomerMapper.selectDcCustomerById(id);
        String ret="";
        if (dcCustomer==null){
            return "数据错误";
        }
        if (dcCustomer.getStatus()==0){
            dcCustomerMapper.updateStatusById(1, id);
            ret= "启用成功";
        }else{
            dcCustomerMapper.updateStatusById(0, id);
            ret="停用成功";
        }
        return ret;
    }

    /**
     * 查询客户管理
     * 
     * @param id 客户管理主键
     * @return 客户管理
     */
    @Override
    public DcCustomer selectDcCustomerById(Long id)
    {
        return dcCustomerMapper.selectDcCustomerById(id);
    }

    /**
     * 查询客户管理列表
     * 
     * @param dcCustomer 客户管理
     * @return 客户管理
     */
    @Override
    public List<DcCustomer> selectDcCustomerList(DcCustomer dcCustomer)
    {
        return dcCustomerMapper.selectDcCustomerList(dcCustomer);
    }

    /**
     * 新增客户管理
     * 
     * @param dcCustomer 客户管理
     * @return 结果
     */
    @Override
    public int insertDcCustomer(DcCustomer dcCustomer)
    {
        return dcCustomerMapper.insertDcCustomer(dcCustomer);
    }

    /**
     * 修改客户管理
     * 
     * @param dcCustomer 客户管理
     * @return 结果
     */
    @Override
    public int updateDcCustomer(DcCustomer dcCustomer)
    {
        return dcCustomerMapper.updateDcCustomer(dcCustomer);
    }

    /**
     * 批量删除客户管理
     * 
     * @param ids 需要删除的客户管理主键
     * @return 结果
     */
    @Override
    public int deleteDcCustomerByIds(Long[] ids)
    {
        return dcCustomerMapper.deleteDcCustomerByIds(ids);
    }

    /**
     * 删除客户管理信息
     * 
     * @param id 客户管理主键
     * @return 结果
     */
    @Override
    public int deleteDcCustomerById(Long id)
    {
        return dcCustomerMapper.deleteDcCustomerById(id);
    }
}
